home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / MKLOGON.CMD < prev    next >
OS/2 REXX Batch file  |  1992-10-25  |  7KB  |  249 lines

  1.     LEGEND "MkLogon ver 1.1"        ; 20 chars long
  2. ;
  3. ; ----- MkLogon: Create logon scripts for COM-AND
  4. ;
  5. ;    R.McG; 7/89, Chicago
  6. ;          10/92, updated for BIX, MCI etc
  7. ; ----------------------------------------------------------------
  8. ; Usages:
  9. ;      S19 -----> Legend line
  10. ;      S18 -----> File name preamble for destination file
  11. ;      S17 -----> Carries the system ID
  12. ;      S16 -----> Carries the system password
  13. ;      S15 -----> System name
  14. ; -----------------------------------------------------------------------
  15. ;
  16. ;    Initialization
  17. ;
  18.     S19 = "_LEGEND"                 ; Set initial legend
  19.     GOTO START            ; And continue
  20. ;
  21. ;    Escape - Clear all windows, and exit
  22. ;
  23. Escape:
  24.     WCLOSE ALL             ; Close all open windows
  25.     EXIT                 ; End script
  26. ;
  27. ;    Draw the menu
  28. ;
  29. Start:
  30.     WOPEN 0,10, 9,70 (default) Escape
  31.     ATSAY 0,12  (Default) " MkLogon "
  32.     ATSAY 1,12  (Default) "1) Create new BIX logon"
  33.     ATSAY 2,12  (Default) "2) Create new CIS logon"
  34.     ATSAY 3,12  (Default) "3) Create new Delphi logon"
  35.     ATSAY 4,12  (Default) "4) Create new GEnie logon"
  36.     ATSAY 5,12  (Default) "5) Create new MCI logon"
  37.     ATSAY 6,12  (Default) "6) Create new UNISON logon"
  38.  
  39.     ATSAY 9,28  (Default) " Press ESC to terminate "
  40. ;
  41. ;    Wait for a keypress
  42. ;
  43. Main:
  44.     KEYGET S1            ; Read a single key
  45.     SWITCH S1
  46.        CASE "1"                     ; BIX
  47.           S18 = "BIX"
  48.           S15 = "BIX"
  49.           ENDCASE
  50.        CASE "2"                     ; CIS
  51.           S18 = "CIS"
  52.           S15 = "CompuServe"
  53.           ENDCASE
  54.        CASE "3"                     ; Delphi
  55.           S18 = "DEL"
  56.           S15 = "Delphi"
  57.           ENDCASE
  58.        CASE "4"                     ; GEnie
  59.           S18 = "GEN"
  60.           S15 = "GEnie"
  61.           ENDCASE
  62.        CASE "5"                     ; MCI
  63.           S18 = "MCI"
  64.           S15 = "MCI"
  65.           ENDCASE
  66.        CASE "6"                     ; UNISON
  67.           S18 = "UNI"
  68.           S15 = "Unison"
  69.           ENDCASE
  70.  
  71.        DEFAULT
  72.           SOUND 100,100         ; Signal displeasure
  73.           GOTO Main          ; Try again
  74.           ENDCASE
  75.     ENDSWITCH
  76. ;
  77. ;    Prompt for an ID
  78. ;
  79.     GOSUB Get_ID            ; Request an ID
  80.     IF FAILED GOTO Main        ; Test return status
  81.     S17 = S0            ; Save ID
  82.  
  83.     GOSUB Get_Psw            ; Request a Psw
  84.     IF FAILED GOTO Main        ; Test return status
  85.     S16 = S0            ; Save PSW
  86. ;
  87. ;    Review the ID and password
  88. ;
  89.     PRESERVE S17            ; Preserve for display/write
  90.     PRESERVE S16            ; Preserve for display/write
  91.     GOSUB Review            ; Review ID and psw
  92.     IF FAILED GOTO Main        ; Test return status
  93. ;
  94. ;    Create an unencrypted logon file
  95. ;
  96.     S10 = S18&"LOGON.CMD"
  97.     FOPENO S10 TEXT         ; Purge file if it exists
  98.     IF FAILED
  99.        S19 = "Error opening "*S10
  100.        GOTO Error            ; Exit if error
  101.        ENDIF
  102.     IF STRCMP S18 "GEN"             ; Special case for GEnie
  103.        S0 = "TRANSMIT `""*S17&","*S16*"!!`"!"
  104.        LENGTH S0 N0
  105.        WRITE S0 N0            ; Write a single line
  106.     ELSE                ; Everyone else
  107.        S0 = "TRANSMIT `""*S17*"!!`"!"
  108.        WRITE S0            ; Write a single line
  109.        S0 = "WAITFOR `"password`"!"
  110.        WRITE S0            ; Write a single line
  111.        S0 = "TRANSMIT `""*S16*"!!`"!"
  112.        WRITE S0            ; Write a single line
  113.        ENDIF
  114.     S0 = "IF FCALLED!"
  115.     WRITE S0            ; Write a single line
  116.     S0 = "   FRET!"
  117.     WRITE S0            ; Write a single line
  118.     S0 = "   ENDIF!"
  119.     WRITE S0            ; Write a single line
  120.     FCLOSEO             ; CLose the output file
  121. ;
  122. ;    Finally, ask if the file is to be encrypted
  123. ;
  124.     GOSUB Get_Encrypt        ; Ask for encryption
  125.     IF FAILED GOTO Main        ; Failure here
  126. ;
  127. ;    Encrypt the file
  128. ;
  129.     S11 = S18&"LOGON.ENF"
  130.     ENCRYPT S10,S11,S0 SIMPLE    ; Input, output, password, method
  131.     IF FAILED
  132.        S19 = "Encryption failed on "*S11
  133.        GOTO Error            ; Exit if error
  134.        ENDIF
  135.     DELETE S10            ; Delete unencrypted file
  136.     GOTO Main            ; And continue
  137. ;
  138. ; ----- Subroutine: Open a window and ask for an ID
  139. ;    SUCCESS/Failed returned to indicate ESCape
  140. ;    S0 returns the ID
  141. ;
  142. Get_ID:
  143.     WOPEN 10 10 13 70 (Default) TOP_ESC
  144.     ATSAY 10 ,12 (default)    " MkLogon ID "
  145.     ATSAY 11 ,11 (default)    " Please specify the ID for "*S15
  146.     ATSAY 13  30 (default) " Press ESC to exit "
  147.     ATGET 12, 12 (default) 54 S0
  148.     WCLOSE
  149.     ;
  150.     ;    If null response, return failed
  151.     ;
  152. End_Get:
  153.     SET SUCCESS ON            ; Default return
  154.     LJ S0                ; Left justify
  155.     IF NULL S0 SET SUCCESS OFF
  156.     RETURN
  157.     ;
  158.     ;    ESC hit during topic entry
  159.     ;
  160. TOP_ESC:
  161.     S0 = ""                         ; Make a null return
  162.     RETURN
  163. ;
  164. ; ----- Subroutine: Open a window and ask for a password
  165. ;    SUCCESS/Failed returned to indicate ESCape
  166. ;    S0 returns the password
  167. ;
  168. Get_Psw:
  169.     WOPEN 10 10 13 70 (Default) TOP_ESC
  170.     ATSAY 10 ,12 (default)    " MkLogon Password "
  171.     ATSAY 11 ,11 (default)    " Please specify the password for "*S15
  172.     ATSAY 13  30 (default) " Press ESC to exit "
  173.     ATGET 12, 12 (default) 54 S0
  174.     WCLOSE
  175.     ;
  176.     ;    If null response, return failed
  177.     ;
  178.     GOTO End_Get            ; Exit, setting SUCCESS/FAILURE
  179. ;
  180. ; ----- Subroutine: Review ID and password
  181. ;    SUCCESS/Failed returned to indicate ESCape
  182. ;
  183. Review:
  184.     WOPEN 10 10  16 70 (Default) TOP_ESC
  185.     ATSAY 10 ,12 (default)    " MkLogon Review "
  186.     ATSAY 11 ,12 (default)    " System:   "*S15
  187.     ATSAY 12 ,12 (default)    " ID:       "*S17
  188.     ATSAY 13 ,12 (default)    " Password: "*S16
  189.     ATSAY 15 ,12 (default)    " Is this correct? (y/n): "
  190.     ATSAY 16  30 (default) " Press ESC to cancel "
  191.     ATGET 15, 37 (default) 1  S0
  192.     WCLOSE
  193.     ;
  194.     ;    Interpret the response
  195.     ;
  196.     IF NULL S0 or FIND S0 "Y"
  197.        SET SUCCESS ON
  198.     ELSE
  199.        IF FIND S0 "N"
  200.           SET SUCCESS OFF
  201.        ELSE
  202.           SOUND 100,100
  203.           GOTO Review
  204.           ENDIF
  205.        ENDIF
  206.     RETURN
  207. ;
  208. ; ----- Subroutine: Ask for encryption
  209. ;    SUCCESS/Failed returned to indicate encryption y/n
  210. ;    IF SUCCESS, S0 returns the password
  211. ;
  212. Get_Encrypt:
  213.     WOPEN 10 10  16 70 (Default) TOP_ESC
  214.     ATSAY 10 ,12 (default)    " MkLogon Encrypt "
  215.     ATSAY 11 ,12 (default)    "If you wish to have the logon file encrypted, enter the"
  216.     ATSAY 12 ,12 (default)    "password here.  If you encrypt the file, you must have"
  217.     ATSAY 13 ,12 (default)    "the password everytime you wish to logon."
  218.     ATSAY 15 ,12 (default)    "Encryption password: "
  219.     ATSAY 16  37 (default) " Press ESC to skip "
  220.     ATGET 15, 32 (default) 32 S0
  221.     WCLOSE
  222.     ;
  223.     ;    Interpret the response
  224.     ;
  225.     IF NULL S0
  226.        SET SUCCESS OFF
  227.     ELSE
  228.        SET SUCCESS ON
  229.        ENDIF
  230.     RETURN
  231. ;
  232. ; ----- Fatal error.  Open a window, display a message, and exit
  233. ;    .. Note that this procedure terminates the script
  234. ;
  235. ;    S19 passes the error message
  236. ;
  237. Error:
  238.     WOPEN 10,10,12,70 (contrast) Err_Esc
  239.     ATSAY 10,12 (contrast) " Error "
  240.     ATSAY 11,12 (contrast) S19(0:55); Max msg width 55 chars
  241.     ATSAY 12,26 (contrast) " Press any key to continue "
  242.     ;
  243.     ;    Wait a keypress
  244.     ;
  245.     KEYGET S0            ; Wait for any key
  246. Err_Esc:
  247.     WCLOSE
  248.     EXIT
  249.